﻿using UnityEngine;
using System.Collections;

public class BindToGameObject : MonoBehaviour 
{

    public GameObject ObjectToBindTo;
    public Vector3 Offset = Vector3.zero;
    public float Speed = 2;

    Vector3 target { get { return ObjectToBindTo.transform.TransformPoint(Offset); } }

	// Use this for initialization
	void Start () 
    {
	
	}
	
	// Update is called once per frame
	void Update () 
    {
        transform.position = Vector3.Lerp(transform.position, target, Time.deltaTime * Speed);
    }
}
